package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1PcInstance;
import java.util.ArrayList;
import java.util.Iterator;

public class S_PacketBox extends ServerBasePacket {
  public static final int MSG_WAR_BEGIN = 0;
  
  public static final int MSG_WAR_END = 1;
  
  public static final int MSG_WAR_GOING = 2;
  
  public static final int MSG_WAR_INITIATIVE = 3;
  
  public static final int MSG_WAR_OCCUPY = 4;
  
  public static final int MSG_DUEL = 5;
  
  public static final int MSG_SMS_SENT = 6;
  
  public static final int MSG_MARRIED = 9;
  
  public static final int WEIGHT = 10;
  
  public static final int FOOD = 11;
  
  public static final int MSG_LEVEL_OVER = 12;
  
  public static final int HTML_UB = 14;
  
  public static final int MSG_ELF = 15;
  
  public static final int ADD_EXCLUDE2 = 17;
  
  public static final int ADD_EXCLUDE = 18;
  
  public static final int REM_EXCLUDE = 19;
  
  public static final int ICON_ACTIVESPELLS = 20;
  
  public static final int ICONS2 = 21;
  
  public static final int ICON_AURA = 22;
  
  public static final int MSG_TOWN_LEADER = 23;
  
  public static final int HTML_PLEDGE_RECOMMENDATION_ACCEPT = 25;
  
  public static final int MSG_RANK_CHANGED = 27;
  
  public static final int MSG_WIN_LASTAVARD = 30;
  
  public static final int MSG_FEEL_GOOD = 31;
  
  public static final int SOMETHING1 = 33;
  
  public static final int ICON_BLUEPOTION = 34;
  
  public static final int ICON_POLYMORPH = 35;
  
  public static final int ICON_CHATBAN = 36;
  
  public static final int GUI_PET_EQUITMENT = 37;
  
  public static final int HTML_CLAN1 = 38;
  
  public static final int ICON_I2H = 40;
  
  public static final int CHARACTER_CONFIG = 41;
  
  public static final int LOGOUT = 42;
  
  public static final int MSG_CANT_LOGOUT = 43;
  
  public static final int ICON_WIND_SHACKLE = 44;
  
  public static final int CALL_SOMETHING = 45;
  
  public static final int MSG_COLOSSEUM = 49;
  
  public static final int HTML_CLAN2 = 51;
  
  public static final int COOK_WINDOW = 52;
  
  public static final int ICON_COOKING = 53;
  
  public static final int FISHING = 55;
  
  public static final int DOLL = 56;
  
  public static final int ICON_WIS_POTION = 57;
  
  public static final int ICON_WATER_LIFE_CANCEL = 59;
  
  public static final int ICON_THIRD_SPEED = 60;
  
  public static final int ALLIANCE_LIST = 62;
  
  public static final int MINIGAME_GAMESTART = 64;
  
  public static final int MINIGAME_COUNTDOWN_1 = 65;
  
  public static final int MINIGAME_PLAYERINFO = 66;
  
  public static final int MINIGAME_LAP = 67;
  
  public static final int MINIGAME_WINNER = 68;
  
  public static final int MINIGAME_GAMEOVER = 69;
  
  public static final int MINIGAME_COUNTDOWN_1_END = 70;
  
  public static final int MINIGAME_COUNTDOWN_2 = 71;
  
  public static final int MINIGAME_COUNTDOWN_2_END = 72;
  
  public static final int ICON_WEAPON_BREAKER = 74;
  
  public static final int ICON_WEAKNESS = 75;
  
  public static final int MSG_WAR_BEGIN1 = 78;
  
  public static final int MSG_WAR_END1 = 79;
  
  public static final int MSG_WAR_GOING1 = 80;
  
  public static final int ICON_EINHASADS_BLESS = 82;
  
  public static final int BLUE_EXPREPLY = 86;
  
  public static final int GUI_VISUAL_EFFECT = 83;
  
  public static final int MSG_COLOR_MESSAGE = 84;
  
  public static final int GUI_KARMA = 87;
  
  public static final int DODGE_RATE_PLUS = 88;
  
  public static final int ICON_BLOOD_STAIN = 100;
  
  public static final int DODGE_RATE_MINUS = 101;
  
  public static final int GUI_DRAGON_GATE = 102;
  
  public static final int UPDATE_OLD_PART_MEMBER = 104;
  
  public static final int PATRY_UPDATE_MEMBER = 105;
  
  public static final int PATRY_SET_MASTER = 106;
  
  public static final int PATRY_MEMBERS = 110;
  
  public static final int MSG_LOCATION = 111;
  
  public static final int ICON_FIGHT = 114;
  
  public static final int HTML_CLAN_WARHOUSE_RECORD = 117;
  
  public static final int ICON_SECURITY_SERVICES = 125;
  
  public static final int ICON_OTHER2 = 127;
  
  public static final int UPDATE_ER = 132;
  
  public static final int MSG_BOOKMARK_SPACE = 141;
  
  public static final int ICON_SOUL_GUARDIAN = 144;
  
  public static final int HTML_MASTER = 146;
  
  public static final int ICON_NO_TIMER = 147;
  
  public static final int ROUND_NUMBER = 156;
  
  public static final int NONE_TIME_ICON = 180;
  
  public static final int MAP_TIMER = 153;
  
  public static final int ICON_OTHER3 = 154;
  
  public static final int MAP_TIME = 159;
  
  public static final int CLAN_EXP = 165;
  
  public static final int HTML_PLEDGE_ANNOUNCE = 167;
  
  public static final int HTML_PLEDGE_REALEASE_ANNOUNCE = 168;
  
  public static final int HTML_PLEDGE_WRITE_NOTES = 169;
  
  public static final int HTML_PLEDGE_MEMBERS = 170;
  
  public static final int HTML_PLEDGE_ONLINE_MEMBERS = 171;
  
  public static final int PLEDGE_EMBLEM_STATUS = 173;
  
  public static final int TOWN_TELEPORT = 176;
  
  public static final int SOULTOWERSTART = 195;
  
  public static final int SOULTOWEREND = 196;
  
  private byte[] _byte;
  
  public S_PacketBox(int subCode, L1PcInstance pc) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 176:
        writeC(1);
        writeH(pc.getX());
        writeH(pc.getY());
        break;
    } 
  }
  
  public S_PacketBox(int subCode, int value) {
    int time;
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 195:
        writeD(value);
        writeH(13532);
        writeH(0);
        break;
      case 196:
        writeD(0);
        writeH(value);
        writeH(0);
        break;
      case 74:
      case 75:
        time = value >> 2;
        writeC(time);
        break;
      case 34:
      case 35:
      case 36:
      case 40:
        writeH(value);
        break;
      case 153:
        writeD(value);
        break;
      case 57:
        writeC(44);
        writeH(value);
        break;
      case 6:
      case 10:
      case 11:
      case 144:
        writeC(value);
        break;
      case 21:
        writeC(0);
        writeC(0);
        writeC(0);
        writeC(value);
        break;
      case 15:
      case 49:
        writeC(value);
        break;
      case 173:
        writeC(1);
        if (value == 0) {
          writeC(0);
        } else if (value == 1) {
          writeC(1);
        } 
        writeD(0);
        break;
      case 56:
        writeH(value);
        break;
      case 120:
        writeH(value);
        break;
      case 132:
        writeC(value);
        break;
      case 83:
        writeC(value);
        break;
      case 52:
        writeC(219);
        writeC(49);
        writeC(223);
        writeC(2);
        writeC(1);
        writeC(value);
        break;
      case 165:
        writeH(value);
        break;
    } 
  }
  
  public S_PacketBox(int subCode, int type, int time) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 22:
        writeC(221);
        writeH(time);
        writeC(type);
        break;
      case 156:
        writeD(type);
        writeD(time);
        writeH(0);
        break;
      case 154:
        writeH(time);
        writeH(type);
        break;
      case 5:
        writeD(type);
        writeD(time);
        break;
      case 180:
        writeC(type);
        writeD(time);
        writeD(3431);
        writeH(0);
        break;
      case 100:
        writeC(type);
        writeH(time);
        break;
      case 147:
        writeC(type);
        writeC(time);
        break;
      case 53:
        writeC(19);
        writeC(11);
        writeC(10);
        writeC(18);
        writeH(2313);
        writeC(208);
        writeC(7);
        writeC(type);
        writeC(38);
        writeH(time);
        writeC(97);
        break;
      case 86:
        writeC(112);
        writeC(1);
        writeC(type);
        writeH(time);
        break;
    } 
  }
  
  public S_PacketBox(L1PcInstance master, ArrayList<L1PcInstance> totalList) {
    this._byte = null;
    writeC(250);
    writeC(146);
    writeC(totalList.size());
    Iterator<L1PcInstance> iterator = totalList.iterator();
    while (iterator.hasNext()) {
      L1PcInstance l1Char = iterator.next();
      writeS(l1Char.getName());
      writeC(l1Char.getLevel());
      writeC(l1Char.getType());
    } 
    writeS(master.getName());
    writeC(master.getLevel());
    writeC(master.getType());
  }
  
  public S_PacketBox(int subCode, String name) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 18:
      case 19:
      case 23:
      case 62:
      case 168:
        writeS(name);
        break;
      case 66:
        writeC(1);
        writeC(0);
        writeC(0);
        writeC(0);
        writeS(name);
        break;
    } 
  }
  
  public S_PacketBox(int subCode, Object[] names) {
    Object[] array;
    int n, i;
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 171:
        writeH(names.length);
        array = names;
        n = names.length;
        i = 0;
        while (i < n) {
          Object name = array[i];
          L1PcInstance pc = (L1PcInstance)name;
          writeS(pc.getName());
          writeC(0);
          i++;
        } 
        break;
      case 17:
        writeC(names.length);
        array = names;
        n = names.length;
        i = 0;
        while (i < n) {
          Object name = array[i];
          writeS(name.toString());
          i++;
        } 
        break;
    } 
  }
  
  public S_PacketBox(int subCode, int value, String msg) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 84:
        writeC(value);
        writeS(msg);
        break;
      case 27:
        writeC(value);
        writeS(msg);
        break;
    } 
  }
  
  public S_PacketBox(int subCode, int type, int type2, int time) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 180:
        writeC(time);
        writeD(type);
        writeD(type2);
        writeH(0);
        break;
    } 
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
